const mongoose = require('./db')
const userSchema = new mongoose.Schema({
  username: String,
  password: String,
  phone: String,
})
const userModel = mongoose.model('user8888', userSchema)


let goods = new mongoose.Schema({
  name: String,
  price: Number,
  img: Array,
  type: String,
  num: Number,
  color: Array,
  size: Array,
  city: String,
  sty: String,
  sc: Array,
  runprice: Number,
  title: String,
  fshop: String,
  sextype: String,
  s_id: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'shop'
  }
})
let shop = new mongoose.Schema({
  name: String,
  type: Array,
  img: String
})
let goodcar = new mongoose.Schema({
  uid: String,
  name: String,
  price: Number,
  img: String,
  gid: {
    type: mongoose.Types.ObjectId,
    ref: 'goods'
  },
  num: Number,
  color: String,
  size: String,
  having: String,
  pname: String
})

let ShopTypeSchema = new mongoose.Schema({
  name: String,
  img: String,
  level: Number,

  pid: {
    type: [mongoose.Schema.Types.ObjectId],
    ref: "shopType",
  },
});
let shopTypeModel = mongoose.model("shopType", ShopTypeSchema, "shopType");

let shopmodel = mongoose.model('shop', shop, 'shop')
let gomodel = mongoose.model('goods', goods, 'goods')
let roomSchema = new mongoose.Schema({
  roomname: String,
  users: [String],
  messages: [
    {
      sender: String,
      content: String,
      timestamp: { type: Date, default: Date.now },
    },
  ],
})
let goodcarmodel = mongoose.model('goodcar', goodcar, 'goodcar')
let roomModel = mongoose.model("room", roomSchema, "room")
module.exports = { gomodel, shopmodel, userModel, roomModel, goodcarmodel }
module.exports = { gomodel, shopmodel, userModel, shopTypeModel, goodcarmodel }
